//
//  T3FPolygon.swift
//  t3_map
//
//  Created by Cunhai Li on 2024/10/22.
//

import CoreLocation
import UIKit

// MARK: - T3Polygon参数配置
public struct T3FPolygonOptions {

    /// 使用颜色填充线条，默认黑色
    public var fillColor: UIColor
    /// 线条点串
    public var points: [CLLocationCoordinate2D]
    /// 笔触的颜色，默认黑色
    public var strokeColor: UIColor
    /// 笔触的宽度-默认1
    public let strokeWidth: CGFloat
    /// 虚线样式，需要设置该属性，设定每个实线段和虚线段的长度，通常和color搭配使用来划虚线
    /// 注意：目前只有腾讯地图生效，高德不支持
    public let dotLine: [Int]?
    public let zIndex: CGFloat
    public var id: String?

    public init(fillColor: UIColor = UIColor.clear,
                points: [CLLocationCoordinate2D],
                strokeColor: UIColor = UIColor(red: 26 / 255.0,
                                               green: 181 / 255.0,
                                               blue: 135 / 255.0,
                                               alpha: 1),
                strokeWidth: CGFloat = 1,
                dotLine: [Int]? = nil,
                zIndex: CGFloat = 0,
                id: String? = nil) {
        self.fillColor = fillColor
        self.points = points
        self.strokeColor = strokeColor
        self.strokeWidth = strokeWidth
        self.dotLine = dotLine
        self.zIndex = zIndex
        self.id = id
    }
}

// MARK: - T3Polygon
public protocol T3FPolygon {
    /// 参数配置
    var options: T3FPolygonOptions { get }

    /// 更新点集
    /// - Parameter points: [CLLocationCoordinate2D]
    func update(points: [CLLocationCoordinate2D])

    /// 设置 fillColor
    /// - Parameter fillColor: UIColor
    func setup(fillColor: UIColor)

    /// 设置 strokeColor
    /// - Parameter strokeColor: UIColor
    func setup(strokeColor: UIColor)

    /// 区域是否当包含前经纬度
    /// - Parameter coordinate: 经纬度
    func container(coordinate: CLLocationCoordinate2D) -> Bool
}
